package com.sywb.chuangyebao.view;

import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.sywb.chuangyebao.R;
import com.sywb.chuangyebao.bean.QARichInfo;
import com.sywb.chuangyebao.contract.EmpryContract;
import com.sywb.chuangyebao.widget.RichEditText;
import com.sywb.chuangyebao.widget.RichTextView;

import java.util.LinkedHashMap;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

public class EmptyActivity extends ActionbarActivity<EmpryContract.Presenter> implements EmpryContract.View {

    @BindView(R.id.empty_title)
    RichTextView emptyTitle;
    @BindView(R.id.empty_content)
    RichEditText emptyContent;
    @BindView(R.id.empty_recycler)
    RecyclerView emptyRecycler;

    @Override
    public int getLayoutId(Bundle bundle) {
        return R.layout.activity_emptyl;
    }

    @Override
    public void initView(Bundle bundle) {
        super.initView(bundle);
        String data = getIntent().getStringExtra("p0");
    }

    @Override
    public void initPresenter() {
        super.initPresenter();
    }

    @OnClick({R.id.tv_add, R.id.tv_complete})
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_add:
                mPresenter.getUserChange();
                break;
            case R.id.tv_complete:
                List<QARichInfo> richInfoList = emptyContent.getAllRichInfo();
                emptyTitle.setExpandView(true);
                emptyTitle.setRichText(emptyContent.getText().toString(), richInfoList);
                break;
        }
        super.onClick(v);
    }

    @Override
    public RecyclerView getRecyclerView() {
        return emptyRecycler;
    }

    @Override
    public void setNoData(boolean isNoData) {
    }

    @Override
    public void userAdd(LinkedHashMap<Integer, String> addMap) {
        emptyContent.insertRich(addMap);
    }

    @Override
    public void userDel(LinkedHashMap<Integer, String> delMap) {
        emptyContent.deleteRich(delMap);
    }
}
